import { get, post } from '/@/utils/http/axios';

const URL = {
  login: '/api/user/login',
  adminLogin: '/api/admin/login',
  register: '/api/user/register',
  detail: '/api/user/detail',
  updateUserInfo: '/api/user/updateUserInfo',
  updateUserPwd: '/api/user/updateUserPwd',
  list: '/api/user/list',
  create: '/api/user/create',
  update: '/api/user/update',
  delete: '/api/user/delete',
};

// 用户登录
export const userLoginApi = async (data) =>
  post({ url: URL.login, params: {}, data: data });

// 管理员登录
export const loginApi = async (data) =>
  post({ url: URL.adminLogin, params: {}, data: data });

// 用户注册
export const userRegisterApi = async (data) =>
  post({ url: URL.register, params: {}, data: data });

// 获取用户详情
export const detailApi = async (params) =>
  get({ url: URL.detail, params: params });

// 更新用户信息
export const updateUserInfoApi = async (data) =>
  post({ 
    url: URL.updateUserInfo, 
    params: {}, 
    data: data,
    headers: { 'Content-Type': 'multipart/form-data;charset=utf-8' }
  });

// 更新用户密码
export const updateUserPwdApi = async (data) =>
  post({ url: URL.updateUserPwd, params: {}, data: data });

// 获取用户列表 (管理员)
export const listApi = async (params) =>
  get({ url: URL.list, params: params });

// 创建用户 (管理员)
export const createApi = async (data) =>
  post({ 
    url: URL.create, 
    params: {}, 
    data: data,
    headers: { 'Content-Type': 'multipart/form-data;charset=utf-8' }
  });

// 更新用户 (管理员)
export const updateApi = async (data) =>
  post({ 
    url: URL.update, 
    params: {}, 
    data: data,
    headers: { 'Content-Type': 'multipart/form-data;charset=utf-8' }
  });

// 删除用户 (管理员)
export const deleteApi = async (params) =>
  post({ url: URL.delete, params: params }); 